﻿namespace c__study_2_27
{
    //类似于单例模式

    class Static
    {
        private static Static _name=new Static();
        public string npc = "面面";
        private Static() {

        }
        public static Static name
         {
            get {
                return _name;
                }
         }


    }

    //静态类
    static class Mathtool
    {
        private static float Pi;
        static Mathtool()
        {
            Pi = 3.14f;
        }
        public static float CalcCircularArea(float r)
        {
            return Pi * Pi * r;
        }
        public static float CalcCircularLength(float r)
        {
            return 2 * Pi * r;
        }
    }
    //拓展
    static class Add
    {
        static public void AddInt(this int i)
        {
            Console.WriteLine("{0}的平方是{1}",i,i*i);
        }
        static public void AddPlayerZiSa(this Player ZiSa)
        {
            Console.WriteLine("{0}选择了自杀",ZiSa.name);
        }
    }
    class Player
    {
        public string  name;
        int blood;
        int attack;
        public Player()
        {
            name = "pl";
            blood = 5;
            attack = 1;
        }
        public void Attack()
        {
            Console.WriteLine("{0}发起了攻击，造成了{1}点伤害", name, attack);
        }
        
    }
    //运算符的重载
    class Position
    {
        public int x;
        public int y;
        public Position(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public static bool operator ==(Position p1, Position p2)
        {
            return p1.x == p2.x && p1.y == p2.y;
        }
        public static bool operator !=(Position p1, Position p2)
        {
            return p1.x != p2.x || p1.y != p2.y;
        }
    }
    class Vector3
    {
        public int x;
        public int y;
        public int z;
        public Vector3(int x, int y, int z)
        {
            this.x = x;
            this.y = y;
            this.z = z;
        }
        public Vector3()
        {

        }
        public static Vector3 operator +(Vector3 v1,Vector3 v2)
        {
            Vector3 v3 = new Vector3();
            v3.x = v1.x + v2.x;
            v3.y = v1.y + v2.y;
            v3.z = v1.z + v2.z;
            return v3;
        }
        public static Vector3 operator *(Vector3 v,int num)
        {
            v.x *= num;
            v.y *= num;
            v.z *= num;
            return v;
        }
    }

    internal class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("名字是{0}", Static.name.npc);
            //Console.WriteLine("圆的半径是{0}，面积是{1}，周长是{2}",4,Mathtool.CalcCircularArea(4.0f),Mathtool.CalcCircularLength(4.0f));
            //int i = 5;
            //i.AddInt();
            //Player player = new Player();
            //player.Attack();
            //player.AddPlayerZiSa();

            //Position p1 = new Position(2, 2);
            //Position p2 = new Position(3, 2);
            //if (p1 != p2)
            //{
            //    Console.WriteLine("1");
            //}
            Vector3 V1= new Vector3(1,2,3);
            Vector3 V2 = new Vector3(3,2,1);
            Vector3 V3=V1 + V2;
            Console.WriteLine("{0},{1},{2}",V3.x,V3.y,V3.z);
            V3 *= 4;
            Console.WriteLine("{0},{1},{2}", V3.x, V3.y, V3.z);

        }
    }
}
